package com.hongxun.modules.api.controller;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.hongxun.modules.api.entity.BOtherCostEntity;
import com.hongxun.modules.api.service.BOtherCostService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hongxun.modules.api.entity.BProjectApplicationEntity;
import com.hongxun.modules.api.service.BProjectApplicationService;
import com.hongxun.common.utils.PageUtils;
import com.hongxun.common.utils.Query;
import com.hongxun.common.utils.R;




/**
 * 配网技改修理项目申请书
 * 
 * @author zkcn
 * @email youeremail@163.com
 * @date 2018-07-25 09:26:34
 */
@RestController
@RequestMapping("/api/bprojectapplication")
public class BProjectApplicationController {
	@Autowired
	private BProjectApplicationService bProjectApplicationService;
	@Autowired
	private BOtherCostService bOtherCostService;
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("api:bprojectapplication:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);
        String wheres =" 1=1 ";
        query.put("filterSql",wheres+" ");
		List<BProjectApplicationEntity> bProjectApplicationList = bProjectApplicationService.queryList(query);
		int total = bProjectApplicationService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(bProjectApplicationList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	@RequestMapping("/select")
     public R select(@RequestParam Map<String, Object> params){
		//查询列表数据
		Query query = new Query(params);
		String wheres =" 1=1 ";
		query.put("filterSql",wheres+" ");
		List<BProjectApplicationEntity> bProjectApplicationList = bProjectApplicationService.queryList(query);
       return R.ok().put("returnlist", bProjectApplicationList);
	}
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{guid}")
	@RequiresPermissions("api:bprojectapplication:info")
	public R info(@PathVariable("guid") String guid){
		BProjectApplicationEntity bProjectApplication = bProjectApplicationService.queryObject(guid);
		
		return R.ok().put("bProjectApplication", bProjectApplication);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("api:bprojectapplication:save")
	public R save(@RequestBody BProjectApplicationEntity bProjectApplication){
		bProjectApplicationService.save(bProjectApplication);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("api:bprojectapplication:update")
	public R update(@RequestBody BProjectApplicationEntity bProjectApplication){
		bProjectApplicationService.update(bProjectApplication);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("api:bprojectapplication:delete")
	public R delete(@RequestBody String[] guids){

		bProjectApplicationService.deleteBatch(guids);


		return R.ok();
	}
	
}
